package com.ruoyi.common.wx.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.sdk.dxoos.OosConfig;
import com.ruoyi.common.sdk.dxoos.OosUtils;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

@Data
@Accessors(chain = true)
@TableName("wx_user")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class WxUser {

    @TableId(value = "id")
    private Long id;

    @TableLogic
    private Integer delFlag;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /** openID */
    private String openId;

    /** 用户头像 */
    private String avatarUrl;

    /** 姓名 */
    @Excel(name = "姓名")
    private String name;

    /** 性别（0=女,1=男,2=未知） */
    private Integer sex;

    /** 手机 */
    @Excel(name = "联系方式")
    private String phone;

    /** 就职单位 */
    @Excel(name = "就职单位")
    private String company;

    /** 担任职务 */
    @Excel(name = "担任职务")
    private String job;

    /* int  userType  1 嘉宾  2 非嘉宾*/
    private Integer userType;

    @TableField(exist = false)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Long metId;

    /**
     * 创建临时访问oos文件的地址
     */
    public void createTmpViewOosUrl(){
        /** 会议地点图片 */
        if(StringUtils.isNotEmpty(avatarUrl))
            avatarUrl = OosUtils.generatePresignedUrl(OosUtils.getKey(avatarUrl), OosConfig.OOS_BUCKET_NAME, 30);
    }
}
